import json

import pytest

from common.yaml_util import write_yaml, read_yaml


@pytest.fixture(scope="function", autouse=True)
def zhuangshiqi001():
    '''
        装饰器@pytest.fixture
        参数：
            scope:作用域 class function
            autouse:是否自动化 True False
    :return:
    '''
    print("zhuangshiqi001运行")
    yield
    print("zhuangshiqi001结束")


@pytest.fixture(scope="function", autouse=False)
def zhuangshiqi002():
    print("zhuangshiqi002运行")
    yield
    print("zhuangshiqi002结束")


class TestPytest:

    # def setup_method(self):
    #     print("---开始执行---")
    #
    # def teardown_method(self):
    #     print("---结束执行---")
    #
    # def setup_class(self):
    #     print("---开始执行TestPytest---")
    #
    # def teardown_class(self):
    #     print("---结束执行TestPytest---")


    def test01(self, zhuangshiqi002):
        print("---测试01执行ing---")
        tmpParam = "临时数据1"
        write_yaml({"data":tmpParam})

    def test02(self):
        print("---测试02执行ing---")
        print("data:",read_yaml()["data"])



